function zerofill(num) {
    return num.toString().length === 1 ? `0${num}` : num;
}

export default function formatTime(time) {
    time = Math.ceil(time);
    const timeFragments = [3600, 60, 1].map(interval => {
        const num = Math.floor(time / interval);
        time -= interval * num;
        return num;
    });
    if (timeFragments[0] === 0) {
        timeFragments.splice(0, 1);
    }

    return timeFragments.map(num => zerofill(num)).join(':');
}
